<script>
  const p = new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest()
    xhr.onreadystatechange = function () {
      if (xhr.readyState === 4) {
        if (xhr.status === 200) {
          let { g: res } = JSON.parse(xhr.responseText)
          console.log(res)
          resolve(res)
        } else {
          reject(xhr.status)
        }
      }
    }
    xhr.open("get", `http://www.baidu.com/a.html`)
    xhr.send(null)
  })
    .then(
      (res) => {},
      (err) => {
        console.log("error:", err)
      }
    )
    .finally(() => {
      console.log("finally!!!")
    })

  // finally 不能处理promise的状态
</script>
